848d1f
@@ -126,17 +126,24 @@
public class HTTPUpgradeService implements Service<HTTPUpgradeService> {
 
                         if (super.handleUpgrade(exchange)) {
                             ActiveMQServer server = selectServer(exchange, activeMQServer);
+                            if (server == null) {
+                                return false;
+                            }
                             // If ActiveMQ remoting service is stopped (eg during shutdown), refuse
                             // the handshake so that the ActiveMQ client will detect the connection has failed
                             RemotingService remotingService = server.getRemotingService();
+                            final String endpoint = exchange.getRequestHeaders().getFirst(getHttpUpgradeEndpointKey());
                             if (!server.isActive() || !remotingService.isStarted()) {
                                 return false;
                             }
-                            final String endpoint = exchange.getRequestHeaders().getFirst(getHttpUpgradeEndpointKey());
                             if (endpoint == null) {
                                 return true;
                             } else {
-                                return acceptorName.equals(endpoint);
+                                if (acceptorName.equals(endpoint)) {
+                                    return !remotingService.isPaused();
+                                } else {
+                                    return false;
+                                }
                             }
                         } else {
                             return false;
@@ -147,7 +154,7 @@
public class HTTPUpgradeService implements Service<HTTPUpgradeService> {
 
     private static ActiveMQServer selectServer(HttpServerExchange exchange, ActiveMQServer rootServer) {
         String activemqServerName = exchange.getRequestHeaders().getFirst(TransportConstants.ACTIVEMQ_SERVER_NAME);
-        if (activemqServerName == null || activemqServerName.equals(rootServer.getConfiguration().getName())) {
+        if (activemqServerName == null) {
             return rootServer;
         }
         ClusterManager clusterManager = rootServer.getClusterManager();
@@ -162,7 +169,11 @@
public class HTTPUpgradeService implements Service<HTTPUpgradeService> {
             }
         }
 
-        return rootServer;
+        if (activemqServerName.equals(rootServer.getConfiguration().getName())) {
+            return rootServer;
+        } else {
+            return null;
+        }
     }
 
     @Override
